package main

import (
	api "holidayOpenAPI/api"
	config "holidayOpenAPI/infrustructure/config"

	_ "holidayOpenAPI/docs"

	"github.com/gin-gonic/gin"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

// @title 测试
// @version 0.0.1
// @description  测试
// @BasePath /api/v1/
func main() {
	//初始化数据库连接
	config.InitDB()
	//初始化并载入路由
	r := gin.Default()
	api.Routes(r)

	//加载静态文件，引入了框架，不得已为之，后期优化
	r.Static("/static", "./static")
	r.Static("/lib", "./static/lib")
	r.Static("/holiday/pages", "./static/pages")
	r.Static("/holiday/static", "./static")
	r.Static("/holiday/lib", "./static/lib")
	r.LoadHTMLGlob("templates/**/**")
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	//绑定9000端口
	r.Run(":8011")
}
